<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>

    function getUsers() {
        // 对象数组
        return [{ name: "zhangsan", age: 20 }, { name: "lisi", age: 25 }, { name: "wangwu", age: 23 }];
    }

// console.log( getUsers());// [{zhangan:20},{lisi:25}]
// 适配不同接口，不同平台；
function adaptor(users){
    let arr = [];
    for(let i=0;i<users.length;i++){
        // arr[users[i].name] = users[i].age;
        let obj = {[users[i].name]:users[i].age};
        arr.push(obj);
    }
    // console.log(arr);
    return arr;
}
let newArr =  adaptor(getUsers());
console.log(newArr);

// axios 适配 浏览器端 和  服务端（nodejs）； 

</script>

</html>